package com.bl.student.dao.model;

import com.bl.student.common.enums.DetailType;
import com.bl.student.common.enums.OnlineStatus;
import com.bl.student.common.enums.SwitchStatus;
import com.bl.student.dao.model.converter.DatetimeConverter;
import com.bl.student.dao.model.converter.JsonConverter;
import com.bl.student.dao.model.custom.DetailItem;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.List;

/**
 * Created by liangweikang on 18/1/20.
 */
@Entity
@Data
@Table(name = "DETAIL")
@ApiModel(value = "DetailEntity", description = "帖子详情")
@DynamicInsert
@DynamicUpdate
public class DetailEntity {

    @Id
    @ApiModelProperty(value = "id")
    private String id;

    @ApiModelProperty(value = "内容")
    @Convert(converter = JsonConverter.DetailItemListConverter.class)
    private List<DetailItem> content;

    @ApiModelProperty(value = "标题")
    private String title;

    @ApiModelProperty(value = "收藏数")
    private int collect;

    @ApiModelProperty(value = "观看数")
    private int view;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "状态")
    private OnlineStatus status;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "贴子类型: CAMPUS 央清校园 PLAN 央清计划 EXPERIENCE 画痨经验 FAVORITE 我想看 NEWS 艺考咨询 COURSE 精品课程 STUDIO 画室 TEACHER 老师 ARENA 擂台")
    private DetailType type;

    @ApiModelProperty(value = "评论状态(OPEN 开启 CLOSE 关闭)")
    @Enumerated(EnumType.STRING)
    private SwitchStatus comment;

    @ApiModelProperty(value = "内容创建者(当详情是ugc时使用)")
    @Column(name = "creator_id")
    private String creatorId;

    @ApiModelProperty(value = "创建时间")
    @Column(name = "create_time")
    @Convert(converter = DatetimeConverter.class)
    private Long createTime;

    @ApiModelProperty(value = "修改时间")
    @Column(name = "update_time")
    @Convert(converter = DatetimeConverter.class)
    private Long updateTime;
}
